package org.zju.demo.mina;

/**
 * Created by ZJDX on 2015/9/17.
 */
public class InfomationHandler {
    private final byte[] buffer;
    public InfomationHandler(byte[] message) {
        this.buffer = message;
    }

    public String handle(){
        String ret = null;
        System.out.println(buffer);
        if (buffer.length != 10) {
            System.out.println("Error message's length is not equal to 10");
            return null;
        }
        if (buffer[0] != 0x5A) {
            System.out.println("Error message's head byte is wrong");
            return null;
        }
        int type = buffer[1];
        if (type == 1) {
            // call Car Handler to handle
            new CarHandler(buffer).handle();
        } else if (type == 2) {
            // call UavHandler handle this
            new UavHandler(buffer).handle();
        }
        return ret;
    }
}
